<template>
  <ContentWrap>
    <!-- 搜索工作栏 -->
    <el-form
      class="-mb-15px"
      :model="queryParams"
      ref="queryFormRef"
      :inline="true"
      label-width="75px"
    >
      <el-form-item label="提交日期" prop="submitTime">
        <el-date-picker
          v-model="queryParams.submitTime"
          value-format="YYYY-MM-DD HH:mm:ss"
          type="datetimerange"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          class="!w-400px"
        />
      </el-form-item>

      <el-form-item label="订单编号" prop="orderId">
        <el-input
          v-model="queryParams.orderId"
          placeholder="请输入订单编号"
          clearable
          @keyup.enter="handleQuery"
          class="!w-240px"
        />
      </el-form-item>

<!--      <el-form-item label="拨交单号" prop="deliveryCode">
        <el-input
          v-model="queryParams.deliveryReceiptId"
          placeholder="请输入拨交单号"
          clearable
          @keyup.enter="handleQuery"
          class="!w-240px"
        />
      </el-form-item>-->
      <el-form-item  label="订单规格" prop="remark"  >
        <el-input
          v-model="queryParams.remark"
          placeholder="请输入订单规格"
          clearable
          @keyup.enter="handleQuery"
          class="!w-180px"
        />
      </el-form-item>
      <el-form-item label="规格型号" prop="type">
        <el-input
          v-model="queryParams.type"
          placeholder="请输入规格型号"
          clearable
          @keyup.enter="handleQuery"
          class="!w-180px"
        />
      </el-form-item>


      <el-form-item label="转出部门" prop="outDeptName">
        <el-input
          v-model="queryParams.outDeptName"
          placeholder="请输入转出部门"
          clearable
          @keyup.enter="handleQuery"
          class="!w-180px"
        />
      </el-form-item>
      <el-form-item label="转入部门" prop="recvDeptName">
        <el-input
          v-model="queryParams.recvDeptName"
          placeholder="请输入转入部门"
          clearable
          @keyup.enter="handleQuery"
          class="!w-180px"
        />
      </el-form-item>


      <el-form-item>
        <el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
        <el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>

      </el-form-item>
    </el-form>

  <!-- 列表 -->
    <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
<!--
      <el-table-column label="序号" align="center" type="index" />
-->
      <el-table-column label="订单编号" align="center" prop="orderId" />
      <el-table-column label="规格型号" align="center" prop="type" />
      <el-table-column label="转出部门" align="center" prop="outDeptName" />

      <el-table-column label="内码"   width="240px" align="center" prop="internalCode" />
<!--
      <el-table-column label="成品码" align="center" prop="productionCode" />
-->
      <el-table-column label="订单规格" align="center" prop="remark" />
      <el-table-column label="转入部门" align="center" prop="recvDeptName" />z
      <el-table-column
        label="最后一次集采时间"
        align="center"
        prop="lastCollectionTime"
        :formatter="dateFormatter"
        width="180px"
      />
    </el-table>
    <!-- 分页 -->
    <Pagination
      :total="total"
      v-model:page="queryParams.pageNo"
      v-model:limit="queryParams.pageSize"
      @pagination="getList"
    />
  </ContentWrap>

</template>

<script setup lang="ts">
import { dateFormatter } from '@/utils/formatTime'
import { DeliveryReceiptDetailApi, DeliveryReceiptDetailVO } from '@/api/hcxly/deliveryreceiptdetail'

/** 拨交单明细 列表 */
defineOptions({ name: 'DeliveryReceiptDetail' })

const message = useMessage() // 消息弹窗
const { t } = useI18n() // 国际化

const loading = ref(true) // 列表的加载中
const list = ref<DeliveryReceiptDetailVO[]>([]) // 列表的数据
const total = ref(0) // 列表的总页数
const queryParams = reactive({
  pageNo: 1,
  pageSize: 10,
  deliveryReceiptId: undefined,
  orderId: undefined,
  internalCode: undefined,
  productionCode: undefined,
  type: undefined,
  lastCollectionTime: [],
  outDeptId: undefined,
  outDeptName: undefined,
  recvDeptId: undefined,
  recvDeptName: undefined,
  submitTime: [],
  remark: undefined,
  createTime: []
})
const queryFormRef = ref() // 搜索的表单


/** 查询列表 */
const getList = async () => {
  loading.value = true
  try {
    const data = await DeliveryReceiptDetailApi.getDeliveryReceiptDetailPage(queryParams)
    list.value = data.list
    total.value = data.total
  } finally {
    loading.value = false
  }
}

/** 初始化 **/
onMounted(() => {
  getList()
})



/** 搜索按钮操作 */
const handleQuery = () => {
  queryParams.pageNo = 1
  getList()
}


/** 重置按钮操作 */
const resetQuery = () => {
  queryFormRef.value.resetFields()
  handleQuery()
}

</script>
